/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
export const compare = (str1, str2) => {
    if (!str1.trim() || !str2.trim()) return false;
    // 去除空格
    const strToken = str => {
        const arr = [];
        str = str.trim();
        let left = 0;
        let right = 0;
        while (right < str.length) {
            if (str[right] === ' ' && str[right + 1] !== ' ') {
                arr.push(str.slice(left, right).trim());
                left = right;
            }
            right++;
        }
        return arr;
    };

    const arr1 = strToken(str1);
    const arr2 = strToken(str2);
    if (arr1.length !== arr2.length) return false;
    let index = 0;
    const len = arr1.length;
    while (index < len) {
        if (arr1[index] !== arr2[index]) return false;
        index++;
    }
    return true;
};
